package com.everyline.baselibrary.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import com.blankj.utilcode.util.LogUtils

/**
 * Created by on 2020/11/30.
 * 天天挂线
 *  746608431@qq.com
 *  描述:TODO
 */

class VerificationSeekBar @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) :
    androidx.appcompat.widget.AppCompatSeekBar(context, attrs, defStyleAttr) {

    //这两个值为用算法使用的2空间复杂度
    private val index = 150
    private var k = true

    override fun dispatchTouchEvent(event: MotionEvent?): Boolean {

        var thumbLeft = thumb.bounds.left
        var thumbRight = thumb.bounds.right
        var eventX = event!!.x.toInt()

        LogUtils.d("VerificationSeekBar=====thumbLeft===$thumbLeft===thumbRight==$thumbRight===eventX===$eventX")
        if (event.action == MotionEvent.ACTION_DOWN) {
            if (eventX <= thumbLeft || eventX > thumbRight) {
                return false
            }
        }

//        val x = event!!.x.toInt()
//        if (event.action == MotionEvent.ACTION_DOWN) {
//            k = true
//            if (x - index > 20) {
//                k = false
//                return true
//            }
//        }
//        if (event.action == MotionEvent.ACTION_MOVE) {
//            if (!k) {
//                return true
//            }
//        }
        return super.dispatchTouchEvent(event)
    }


}